<%@page import="org.apache.jasper.tagplugins.jstl.core.ForEach"%>
<%@page import="studio.modelo.TipoRecurso"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@include file="cabecera.jsp" %>
<%@page import="studio.negocio.SeguridadInstrumento,java.util.*" %>
<%@page import="studio.modelo.Instrumento" %>
  <% 
	SeguridadInstrumento negIntru = new SeguridadInstrumento();
    Collection<Instrumento> lstInstr = new ArrayList<Instrumento>();
    lstInstr=negIntru.ListarIntrume();
    request.setAttribute("LstInstru",lstInstr );
    
    Collection<TipoRecurso> ListaRecurso=negIntru.LstTipRec();
    request.setAttribute("LstRecursos",ListaRecurso);
    
   String idInstru=request.getParameter("intrume");
   request.setAttribute("id",idInstru);
  // request.setAttribute("idIntrume",Integer.parseInt(idInstru));
   
   double precio=0;
   if (idInstru!=null)
   {
   		for (Instrumento x : lstInstr) 
   		{
   			if (x.getIdInstrumento()==Integer.parseInt(idInstru))
   			{
   				precio=x.getCostoxHora();
   					break;
   			}
		}
   }
   else
   {
   		for (Instrumento x : lstInstr) 
   		{
   			if (x.getIdInstrumento()==1)
   			{
   				precio=x.getCostoxHora();
   				idInstru="1";
   				break;
   			}
		}
   }   
   //    for (Sala x : lstSala) {
//	out.println("<li>" + x.getCaracteristicas() + "</li>");
  %>
<form action="AddIntru.jsp" method="post" name="regInstArm">
<table>
<tr>
<td>Intrumento</td>
<td><select name="intrume" onchange="javascript:document.forms[0].submit()" style="width: 169px; ">
<c:forEach items="${requestScope.LstInstru}"  var="p" varStatus="i" >
<option value=${p.getIdInstrumento()}
 <c:if test="${p.getIdInstrumento()==requestScope.id}">
    <c:out value="selected"/>
    </c:if>
>${p.getCaracteristicas()}</option>
</c:forEach>
</select></td>
</tr>
<tr>
<td>Precio</td><td><input type="text" name="precio" value=<%=precio %>></td>
</tr>
<tr>
<td>Recurso</td>
<td><select name="recurso" style="width: 168px; ">
<c:forEach items="${requestScope.LstRecursos}"  var="p" varStatus="i" >
<option value=${p.getIdTipoRecurso()} 


>${p.getDescripcion()}</option>
</c:forEach>
</select>
</td>
</tr>
<tr>
<td>Cantidad</td>
<td><input type="text" name="canti"></td>
</tr>
<tr>
<td></td>
<td>
<button type="button" onclick="javascript:RegInstrArmado()">
<img src="imagenes/save.png" alt="" style="height: 17px; "/> 
Insertar al Armado
</button> 
</td>
</tr>
</table>
</form>
<%@include file="pie.jsp" %>